package cn.itcast.n4;

import java.util.concurrent.TimeUnit;

/**
 * className: TestThreadStatus
 * description:
 * date: 2023/3/8 0008-15:11
 * <p>
 * project: concurrent
 * package: cn.itcast.n4
 * email: 1085844536@qq.com
 * version:
 *
 * @author WangGuojian
 */
public class TestThreadStatus {
    static final Object OBJ = new Object();

    public static void main(String[] args) throws InterruptedException {
        new Thread(() -> {
            synchronized (OBJ) {
                try {
                    OBJ.wait();
                    Thread thread = Thread.currentThread();
                    System.out.println(thread.getName() + " " + thread.getState());
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();

        new Thread(() -> {
            synchronized (OBJ) {
                try {
                    OBJ.wait();
                    Thread thread = Thread.currentThread();
                    System.out.println(thread.getName() + " " + thread.getState());
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();

        TimeUnit.SECONDS.sleep(1);
        synchronized (OBJ) {
            System.out.println("notify begin ..."); // 断点
            OBJ.notifyAll();
        }
        System.out.println("notify end ..."); // 断点

    }
}
